package com.zyj.controller;

import com.zyj.beans.Student;
import com.zyj.services.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


@Controller
@RequestMapping("/student")
public class StudentController {
    @Resource
    private StudentService studentService;
    
    @RequestMapping("/list")
    public String queryAll(HttpServletRequest request){
        List<Student> students = studentService.queryAll();
        request.setAttribute("students", students);
        return "student";
    }

    @RequestMapping("/stus")
    @ResponseBody
    public List<Student> queryStudents(){
        return studentService.queryAll();
    }
}